home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 25 / AACD 25.iso / AACD / Magazine / Online / QMail / patches / qmail-relayclient.diff < prev    next >
Encoding:
Text File  |  1997-10-02  |  2.2 KB  |  90 lines

  1. diff --unified --new-file ../qmail-1.01-unmodified/qmail-smtpd.c ./qmail-smtpd.c
  2. --- ../qmail-1.01-unmodified/qmail-smtpd.c    Tue Apr 15 07:05:23 1997
  3. +++ ./qmail-smtpd.c    Wed Sep 10 12:25:40 1997
  4. @@ -62,6 +62,9 @@
  5.  stralloc helohost = {0};
  6.  stralloc mailfrom = {0};
  7.  stralloc rcptto = {0};
  8. +stralloc relayclients = {0};
  9. +stralloc relaydomains = {0};
  10. +struct constmap maprelayclients, maprelaydomains;
  11.  int seenmail = 0;
  12.  
  13.  stralloc addr = {0}; /* will be 0-terminated, if addrparse returns 1 */
  14. @@ -80,6 +83,9 @@
  15.  
  16.  void getenvs()
  17.  {
  18. + unsigned short int error = 0;
  19. + unsigned int i, len;
  20. +
  21.   remoteip = env_get("TCPREMOTEIP");
  22.   if (!remoteip) remoteip = "unknown";
  23.   local = env_get("TCPLOCALHOST");
  24. @@ -89,6 +95,65 @@
  25.   if (!remotehost) remotehost = "unknown";
  26.   remoteinfo = env_get("TCPREMOTEINFO");
  27.   relayclient = env_get("RELAYCLIENT");
  28. + if (! relayclient)
  29. + {
  30. +   /* Attempt to look up the IP number in control/relayclients. */
  31. +   switch (control_readfile (&relayclients, "control/relayclients", 0))
  32. +   {
  33. +     case -1:
  34. +     if (errno == error_nomem)
  35. +       outofmem ();
  36. +     /* Fall through. */
  37. +
  38. +     case 0:
  39. +     error = 1;
  40. +     break;
  41. +
  42. +     case 1:
  43. +     if (!constmap_init (&maprelayclients, relayclients.s, relayclients.len, 1))
  44. +       outofmem ();
  45. +     break;
  46. +   }
  47. +
  48. +  if (! error)
  49. +  {
  50. +    for (i = len = str_len (remoteip); i > 0; i --)
  51. +      if ((i == len) || (remoteip[i - 1] == '.'))
  52. +        if ((relayclient = constmap (&maprelayclients, remoteip, i)))
  53. +          break;
  54. +  }
  55. + }
  56. +
  57. + error = 0;
  58. + if (! relayclient)
  59. + {
  60. +   /* Attempt to look up the host name in control/relaydomains. */
  61. +   switch (control_readfile (&relaydomains, "control/relaydomains", 0))
  62. +   {
  63. +     case -1:
  64. +     if (errno == error_nomem)
  65. +       outofmem ();
  66. +     /* Fall through. */
  67. +
  68. +     case 0:
  69. +     error = 1;
  70. +     break;
  71. +
  72. +     case 1:
  73. +     if (!constmap_init (&maprelaydomains, relaydomains.s, relaydomains.len, 1))
  74. +       outofmem ();
  75. +     break;
  76. +   }
  77. +
  78. +  if (! error)
  79. +  {
  80. +    for (i = 0, len = str_len (remotehost); i <= len; i ++)
  81. +      if ((i == 0) || (i == len) || (remotehost[i] == '.'))
  82. +        if ((relayclient = constmap (&maprelaydomains, remotehost + i, len - i)))
  83. +          break;
  84. +  }
  85. + }
  86. +
  87.   dohelo(remotehost);
  88.  }
  89.  
  90.